<template>
  <div>
    <div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>

      <div>&nbsp;</div>
      <div>&nbsp;</div>

      <van-row gutter="20">
        <van-col span="8">&nbsp;</van-col>
        <van-col span="8">
          <div align="center">
            <img :src="data.image" width="40" height="40">
          </div>
        </van-col>
        <van-col span="8">
          <van-button
            v-if="data.private_channel_id"
            size="small"
            @click.native="handleGo"
          >
            去咨询
          </van-button>

          <van-button v-else size="small" @click.native="handlePlus">
            关注
          </van-button>
        </van-col>
      </van-row>

      <van-row :gutter="20">
        <van-col :span="6"> &nbsp;</van-col>
        <van-col :span="6">
          <div align="right">
            {{ data.name }}
          </div>
        </van-col>
        <van-col :span="6"> {{ data.title__name }} </van-col>
        <van-col :span="6"> &nbsp;</van-col>
      </van-row>

      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div align="center">
        {{ data.comment }}
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant'

export default {
  name: 'PartnerEmployee',
  components: {},
  directives: {},
  filters: {},
  props: {},

  data() {
    return {
      chatPath: '/mail/chat',
      currentRow: {}
    }
  },
  computed: {
    data: function() {
      return this.$store.state.ResPartnerEmp.dataDict
    }
  },
  async created() {
    const { id } = this.$route.query
    await this.$store.dispatch('ResPartnerEmp/browse_one', { id })
    this.$store.dispatch('header/set', {
      title: this.data.name
    })
  },

  methods: {
    async handleGo() {
      this.$router.push({
        path: this.chatPath,
        query: { id: this.data.private_channel_id }
      })
    },
    async handlePlus() {
      await this.$store.dispatch('ResPartnerEmp/channel_get', {
        id: this.data.id
      })

      Toast.success('关注成功, 可以去咨询了')
    }
  }
}
</script>

<style type="text/css"></style>
